/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2021-11-26
 * Time:20:56
 */
class WriteWordThread extends Thread
{
    int n = 0;
    WriteWordThread(String s, int n)
    {
        setName(s);
        this.n = n;
    }
    public void run()
    {
        for(int i=1; i<=3; i++)
        {
            System.out.println("Thread: " + getName());
            try
            {
                sleep(n);//休眠 - 中断线程
            }
            catch(InterruptedException e) {}
        }
    }
}

public class Example8_2 {
    public static void main(String args[])
    {
        WriteWordThread zhang, wang;
        zhang = new WriteWordThread("Zhang", 200);
        wang = new WriteWordThread("Wang", 100);
        zhang.start();
        wang.start();
    }
    //多次运行结果不一样
}
